package com.gem.springbootdemo.service.Impl;

import com.gem.springbootdemo.entity.Order;
import com.gem.springbootdemo.mapper.OrderMapper;
import com.gem.springbootdemo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class OrderServiceImpl implements OrderService {
@Autowired
    private OrderMapper orderMapper;
    @Override
    @Transactional
    public boolean createOrder(Order order,int uid,int num) {
        boolean flag=orderMapper.insertIntoOrder(order);
        if (flag){
            //order的id有值,自增长的主键
            orderMapper.insertIntoDetail(order.getId(),uid,num);
        }
        return false;
    }
}
